package com.test.gpa.domain;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.Proxy;
import javax.persistence.Id;
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Entity
@Getter
@Setter
@Table(name = "student")
public class Student implements Serializable {
    private static final long serialVersionUID = 5450815487641580632L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "\"name\"")
    private String name;

    @Column(name = "class_name")
    private String className;

    @Column(name = "\"like\"")
    private String like;

    @ManyToMany/*(mappedBy = "students")*/(cascade = CascadeType.ALL )
    @JoinTable(name = "book_student",
            joinColumns = {@JoinColumn(name = "student_id",referencedColumnName = "id")},//name=中间表的外键名 referencedColumnName=该外键在本表的名字

            inverseJoinColumns = {@JoinColumn(name = "book_id",referencedColumnName = "id")}//name=另一张表在中间表的外键名 referencedColumnName=该外键在另一张表的名字
    )
    private Set<Book> books = new HashSet<>(0);

    @Column(name="dorm_id")
    private Long dormId;
}
